<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-log__log-work}">
      <div class="ba-operate-form">
        <el-form :model="dataForm" @keyup.enter.native="getDataList()" label-width="70px">
          <el-row :gutter="20">
            <el-col :md="6" :sm="6">
              <el-form-item label="作业名称">
                <el-input v-model="dataForm.workName" placeholder="模糊查询" maxlength="32" clearable></el-input>
              </el-form-item>
            </el-col>
            <el-col :md="12" :sm="12">
              <el-form-item label="相关编号">
                <el-input v-model="dataForm.relateNo" placeholder="精确匹配" maxlength="32" clearable></el-input>
              </el-form-item>
            </el-col>
            <el-col :md="6" :sm="6">
              <div class="right-handle-group">
                <el-button-group>
                  <el-button @click="getDataList()" type="primary">{{ $t('query') }}</el-button>
                  <el-button @click="getReset()">{{ $t("reset") }}</el-button>
                  <el-tooltip class="item" effect="dark" content="高级搜索" placement="top-start">
                    <el-button @click="advanced = !advanced" color="#dcdfe6" icon="el-icon-search" plain></el-button>
                  </el-tooltip>
                </el-button-group>
              </div>
            </el-col>
          </el-row>
          <el-collapse-transition>
            <div v-show="advanced">
              <el-row :gutter="20">
                <el-col :md="6" :sm="9">
                  <el-form-item label="作业详情">
                    <el-input v-model="dataForm.workMsg" placeholder="模糊匹配" maxlength="20" clearable></el-input>
                  </el-form-item>
                </el-col>
                <el-col :md="6" :sm="9">
                  <el-form-item label="相关过程">
                    <el-input v-model="dataForm.workProc" placeholder="模糊匹配" maxlength="20" clearable></el-input>
                  </el-form-item>
                </el-col>
                <el-col :md="8" :sm="12">
                  <el-form-item label="创建日期">
                    <el-date-picker v-model="dateRange" value-format="yyyy-MM-dd HH:mm:ss" type="datetimerange"
                      range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
                      :picker-options="pickerOptions">
                    </el-date-picker>
                  </el-form-item>
                </el-col>
              </el-row>
            </div>
          </el-collapse-transition>
        </el-form>
      </div>

      <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle"
        style="width: 100%;">
        <el-table-column prop="id" label="id" header-align="center" align="center" sortable></el-table-column>
        <el-table-column prop="workName" label="作业名称" header-align="center" align="center"
          width="150"></el-table-column>
        <el-table-column prop="relateNo" label="相关编号" header-align="center" align="center"
          width="220"></el-table-column>
        <el-table-column prop="workCode" label="作业编号" header-align="center" align="center"></el-table-column>
        <el-table-column prop="workMsg" label="作业详情" header-align="center" align="left" width="500"
          show-overflow-tooltip></el-table-column>
        <el-table-column prop="workProc" label="涉及过程" header-align="center" align="left" width="200"
          show-overflow-tooltip></el-table-column>
        <el-table-column prop="workSec" label="耗时" header-align="center" align="center"></el-table-column>
        <el-table-column prop="creatorName" label="作业员" header-align="center" align="center"></el-table-column>
        <el-table-column prop="createDate" label="创建日期" header-align="center" align="center" width="155"
          sortable></el-table-column>
      </el-table>
      <el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total"
        layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle">
      </el-pagination>

    </div>
  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
export default {
  mixins: [mixinViewModule],
  data() {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/sys/log/work/page',
        exportURL: '/sys/log/work/export',
        getDataListIsPage: true,
      },
      dataForm: {
        id: '',
        workName: '',
        relateNo: '',
        workMsg: '',
        workProc: '',
        startDate: '',
        endDate: '',
      },
      //日期范围
      dateRange: [],
      pickerOptions: {
        shortcuts: [
          {
            text: "当天",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setHours(0, 0, 0);

              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            },
          }
        ]
      },
      advanced: false, //高级搜索
    }
  },
  methods: {
    //0.重置搜索框
    getReset() {
      this.dataForm = this.$options.data().dataForm;
      this.dateRange = this.$options.data().dateRange;
    }
  }
}
</script>
<style>
.el-row {
  margin-bottom: 0px;
}

.right-handle-group {
  float: right;
}
</style>
